package harima.agameditor.mapeditor.ui.dialogs;

import java.awt.BorderLayout;

import harima.agameditor.common.resources.CommonCommands;
import harima.agameditor.mapeditor.control.MapEditorController;
import harima.agameditor.resources.Labels;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;

public class NewMapDialog extends JDialog{

	MapEditorController controller;
	
	JButton aceptButton;
	JButton cancelButton;
	JTextField mapName;
	JSpinner mapWidth;
	JSpinner mapHeight;
	JSpinner tileWidth;
	JSpinner tileHeight;
	
	public NewMapDialog()
	{
		JPanel buttonsPanel = createButtonsPanel();
		JPanel mapProperties = createMapPropertiesPanel();
		JPanel tileProperties = createTileProperties();
		
		setLayout(new BorderLayout());
		JPanel centerPanel = new JPanel();
		centerPanel.add(mapProperties);
		centerPanel.add(tileProperties);
		add(centerPanel, BorderLayout.CENTER);
		add(buttonsPanel, BorderLayout.SOUTH);
		
		setTitle(Labels.NewMapDialogTitle);
	}

	private JPanel createTileProperties() {
		tileHeight = new JSpinner();
		tileWidth = new JSpinner();
		tileHeight.setValue(16);
		tileWidth.setValue(16);
		JPanel panel = new JPanel();
		panel.add(tileWidth);
		panel.add(tileHeight);
		return panel;
	}

	private JPanel createMapPropertiesPanel() {
		mapName = new JTextField(15);
		mapWidth = new JSpinner();
		mapHeight = new JSpinner();
		mapHeight.setValue(30);
		mapWidth.setValue(30);
		JPanel panel = new JPanel();
		panel.add(mapName);
		panel.add(mapWidth);
		panel.add(mapHeight);
		return panel;
	}

	private JPanel createButtonsPanel() {
		aceptButton = new JButton(CommonCommands.Acept);
		aceptButton.setActionCommand(CommonCommands.Acept);
		cancelButton = new JButton(CommonCommands.Cancel);
		cancelButton.setActionCommand(CommonCommands.Cancel);
		JPanel panel = new JPanel();
		panel.add(aceptButton);
		panel.add(cancelButton);
		return panel;
		
	}
}
